package IOPackage1;

import java.io.*;
import java.util.Arrays;

/**
 * @Auther:SunPeng
 * @Date:2020/7/29-07-29
 * @Description:IOPackage1
 * @version:1.0
 */
public class IODemo {
    public static void main(String[] args) {

        FileReader in = null;
        try{
            in = new FileReader("E:\\IDEAProject\\IOPoject\\src\\IOPackage1\\IODemo.java");
        }catch (FileNotFoundException e){
            System.out.println("找不到文件");
            System.exit(-1);
        }

        char[] buffer = new char[100];
        try{
            long num = 0;
            long nums = 0;
            while ((num = in.read(buffer)) != -1){
                System.out.print(buffer);
                nums+=num;
                Arrays.fill(buffer,'\0');
            }
            in.close();
            System.out.println("\n"+"共读取了 "+nums+" 个字节");
        }catch (IOException e1){
            System.out.println("文件读写错误");
            System.exit(-1);
        }
    }
}
